package org.example.mybatis.test;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.example.mybatis.bean.Emp;
import org.example.mybatis.mapper.EmpMapper;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

@Slf4j
@SpringBootTest
public class App {
    @Resource
    private EmpMapper mapper;
    @Test
    public void a() {
        List<Emp> list = mapper.find();
        for (Emp emp : list) {
            log.info("emp:{}",emp);
        }
    }
    @Test
    public void b(){
        Emp emp = new Emp();
        emp.setComm(8888.8);
        emp.setJob("程序员");
        emp.setMgr(6666);
        emp.setDeptNo(18);
        emp.setSal(29999.9);
        emp.setEname("lili");
        boolean b = mapper.save(emp);
        log.info("b:{}",b);
    }
    @Test
    public void c(){
        Emp emp = new Emp();
        emp.setMgr(8888);
        emp.setSal(49999.9);
        emp.setEmpNo(8040);
        boolean b = mapper.update(emp);
        log.info("b:{}",b);
    }
    @Test
    public void d(){
        boolean b = mapper.delete(8039);
        log.info("b:{}",b);
    }
}
